<template>
  <div class="FileData">
    <div class="block">
      <el-timeline v-if="tableData.length > 0">
        <el-timeline-item icon="el-icon-circle-check" v-for="(item, index) in tableData" :key="index" :type="item.TASK_STATUS == '5' ? 'success' : 'info'" :timestamp="item.NODE_NAME" placement="top">
          <div class="year">
            <el-button :type="item.TASK_STATUS == '5' ? 'success' : 'info'" size="mini">{{ item.TASK_STATUS == '5' ? '已处理' : '未处理' }}</el-button>
          </div>
          <el-card style="font-size: 14px">
            <div class="cardkls">
              <p style="color: #4bc29c">接收时间：{{ item.TASK_RECIEVEDATE }}</p>
              <p style="color: #4bc29c" v-if="item.NODE_NAME == '村公示'">公示时间：{{ item.TASK_RECIEVEDATE }}</p>
              <p style="color: #4bc29c" v-if="item.NODE_NAME == '规划批前公示环节'">公示时间：{{ item.GHPQ_TIME }}</p>
              <p style="color: #dc6f72">结束时间：{{ item.TASK_ENDTIME || '暂无数据' }}</p>
              <p>操作人：{{ item.TASK_RECIPIENTNAME }}</p>
              <div style="height: auto; font-size: 16px">审核意见：{{ item.TASK_SHYJ }}</div>
              <van-collapse v-model="activeNames" v-if="item.NODE_NAME == '村级预审'">
                <van-collapse-item title="附件列表" name="1">
                  <upLoad
                    id="upLoad1"
                    :ISDelete="true"
                    :rowData="rowData"
                    :FJData="file"
                    :CUNID="rowData.ROW_GUID"
                    :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
                    :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
                </van-collapse-item>
              </van-collapse>
              <van-collapse v-model="activeNames1" v-if="item.NODE_GUID == '{BF5EBF92-26ED-46F4-A7E5-EFFDD7C8BE0C}'">
                <van-collapse-item title="附件列表" name="2">
                  <upLoad
                    id="upLoad1"
                    :ISDelete="true"
                    :rowData="rowData"
                    :FJData="fileCUN"
                    :CUNID="ROW_GUID1"
                    :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
                    :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
                </van-collapse-item>
              </van-collapse>
              <van-collapse v-model="activeNames3" v-else-if="item.NODE_NAME == '现场踏勘'">
                <van-collapse-item title="附件列表" name="0">
                  <!-- <upLoad id="upLoad1" :ISDelete="true" :rowData="rowData" :CUNID="rowData.ROW_GUID"
                                        :FJData="fileTK"
                                        :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
                                        :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" /> -->
                  <upLoad
                    :typeParam="true"
                    :tkRowGuid="tkRowGuid"
                    :rowData="rowData"
                    :FJData="fileData"
                    :isReadOnly="false"
                    :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
                    :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
                </van-collapse-item>
              </van-collapse>
              <van-collapse v-model="activeNames2[item.NODE_NAME]" v-else-if="item.NODE_NAME !== '村级预审'">
                <van-collapse-item title="附件列表" name="0">
                  <upLoad
                    id="upLoad1"
                    :ISDelete="true"
                    :rowData="rowData"
                    :CUNID="rowData.ROW_GUID"
                    :FJData="fileListData.filter((its) => its.NODE_NAME === item.NODE_NAME)"
                    :SHITUID="'98bcf528966e48ce896a8b3fd02d45d5'"
                    :UpLoadID="'7a3fc061c866434b8475d3775c9ddcea'" />
                </van-collapse-item>
              </van-collapse>
            </div>
          </el-card>
        </el-timeline-item>
      </el-timeline>
      <div v-else>
        <div style="height: 78vh; text-align: center; padding-top: 20vh">
          <div style="margin-bottom: 10px">
            <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png" />
          </div>
          <div>暂无数据</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { GJDBFunction2 } from '../../utils/queryData'
import { FileServerProxy } from '@/utils/api'
import upLoad from '../../utils/upLoad'
export default {
  data() {
    return {
      tableData: [],
      ROW_GUID: '',
      ROW_GUID1: '',
      activeNames: ['0'],
      activeNames1: ['0'],
      activeNames3: ['0'],
      fileData: [
        {
          title: '宅基地坐落平面位置图',
          FileName: [],
          groupGuid: 'be6c2622-e00f-49ca-b59d-2550fa62fef6',
          fileList: []
        },
        {
          title: '红线图',
          FileName: [],
          groupGuid: 'c34eb13b-b0e0-4c40-9be8-d69d39360d73',
          fileList: []
        },
        {
          title: '踏勘照片1',
          FileName: [],
          groupGuid: '39150119-0da6-494a-b1e9-4bed532fecfd',
          fileList: []
        },
        {
          title: '踏勘照片2',
          FileName: [],
          groupGuid: 'fb00616c-0c03-41dc-b00b-84d3efe3af87',
          fileList: []
        },
        {
          title: '踏勘照片3',
          FileName: [],
          groupGuid: '7cb50c01-d2e1-4119-a0b6-b0443daca71e',
          fileList: []
        },
        {
          title: '其他材料',
          FileName: [],
          groupGuid: '7eb18ff0-5fe4-47ea-a805-68d7731e2609',
          fileList: []
        }
        // {
        //   title: '坐标串',
        //   FileName: [],
        //   groupGuid: 'b6ae9a58-76e4-42c6-94df-0a18a0af0cbf',
        //   fileList: []
        // },
        // {
        //   title: '坐标文件',
        //   FileName: [],
        //   groupGuid: 'ad2bd6ce-ff46-4a19-a6b1-cfc0bbd64daf',
        //   fileList: []
        // }
      ],
      file: [
        {
          title: '身份证正面照片（浙里办）',
          groupGuid: '19902700-f952-4561-a338-5590056dab65',
          FileName: '无',
          fileList: []
        },
        {
          title: '身份证反面照片（浙里办）',
          FileName: '无',
          groupGuid: 'd26fd8fd-0d8a-46ec-af9f-2341ba78fb58',
          fileList: []
        },
        {
          title: '农村宅基地使用承诺书',
          FileName: '无',
          groupGuid: '188027de-4ba9-4218-bcb1-03bf764293fa',
          fileList: []
        },
        {
          title: '代办人手持照片',
          FileName: '无',
          groupGuid: '85f99afa-f0c4-4064-b7a3-84eb417bc43a',
          fileList: []
        },
        {
          title: '农户身份证明材料',
          FileName: [],
          groupGuid: '0e999f18-bd3d-44a9-bb85-fdc016446fd3',
          fileList: []
        },
        {
          title: '独生子女证明材料',
          FileName: [],
          groupGuid: '00e64693-e45f-463a-87a3-09b8cf4460b9',
          fileList: []
        },
        {
          title: '地源证明',
          FileName: [],
          groupGuid: '75dd729a-077a-43ea-8025-5728aa5735dc',
          fileList: []
        },
        {
          title: '结婚证',
          FileName: [],
          groupGuid: 'f57644c7-1d39-4c3f-b847-311d86aeedd7',
          fileList: []
        },
        {
          title: '村委会意见照片',
          FileName: [],
          groupGuid: '8932dee6-9f8b-45d2-acd2-c592da1790e8',
          fileList: []
        },
        {
          title: '四邻意见书',
          FileName: [],
          groupGuid: 'b2044faf-d609-46c5-995e-d9d2bab0af6d',
          fileList: []
        },
        {
          title: '其他材料',
          FileName: [],
          groupGuid: '7eb18ff0-5fe4-47ea-a805-68d7731e2609',
          fileList: []
        }
      ],
      fileCUN: [
        {
          title: '公示回执',
          FileName: '无',
          groupGuid: '8d7aa8c9-9bba-42f4-aa84-d6ab216e89d2',
          fileList: []
        },
        {
          title: '其他材料',
          FileName: '无',
          groupGuid: '7eb18ff0-5fe4-47ea-a805-68d7731e2609',
          fileList: []
        },
        {
          title: '村公示远景照片',
          FileName: '无',
          groupGuid: '563cb165-cf9e-4b6b-ba85-51960abef51f',
          fileList: [],
          isBitian: true
        },
        {
          title: '村公示近景照片',
          FileName: '无',
          groupGuid: '0313a9ba-75d3-44d0-a5b3-0157fb2b1ea2',
          fileList: [],
          isBitian: true
        },
        {
          title: '会议记录',
          groupGuid: 'e02a07e2-0ab7-4acc-b8e6-77f51854f27a',
          FileName: '无',
          fileList: []
        }
      ],
      //   fileREportCUN:[
      //     {
      //        name:"",
      //        repo
      //     }
      // ],
      fileListData: [],
      activeNames2: {},
      tkRowGuid:"",
    }
  },
  components: {
    upLoad
  },
  props: {
    rowData: Object
  },
  mounted() {
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: '流程详情'
      })
        .then((res) => {})
        .catch((err) => {})
    }
  },
  methods: {
    getData: async function (data) {
      const res = await GJDBFunction2('get_Building_process', [{ record_guid: this.rowData.ROW_GUID, record_type: 1 }])
      let newres = [...new Set(res.map((v) => JSON.stringify(v)))].map((s) => JSON.parse(s)) //全结构序列化
      let set = newres.reduce(function (set, item) {
        set[item['NODE_NAME']] = item
        return set
      }, {})
      this.tableData = Object.values(set)
      //item name
      Object.keys(set).forEach((items) => {
        if (items == '村级预审' || items == '村公示') return false
        this.activeNames2[items] = ['0']
      })
      console.log(this.activeNames2, 'newArr')
    },
    getData1: async function () {
      let params = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        params: {
          dataguid: '313d5ddd-2c1b-4f55-82e1-84d5effd9c47',
          searchObject: JSON.stringify([{ field: 'to_row_guid', value: this.rowData.ROW_GUID, operator: '=' }]),
          token: window.localStorage.getItem('token')
        }
      }
      const res = await FileServerProxy(params)
      let data = JSON.parse(res.data.data).Data
      if (data.length > 0) {
        this.ROW_GUID1 = data[0].ROW_GUID
      }
    },
    //获取踏勘rowGUID
    getTK:async function(){
      let  me=this;
      let params = {
        accessCode: '688bd3883572440a859dfd8ba9194e7b',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '',
        params: {
          dataguid: 'a0e224e8-36be-4591-b770-30cabda3514a',
          searchObject: JSON.stringify([{ field: 'TO_ROW_GUID', value: me.rowData.ROW_GUID, operator: '=' }])
        }
      }
      const res = await FileServerProxy(params)
      if (JSON.parse(res.data.data) && JSON.parse(res.data.data).Data.length > 0) {
        //有数据自动回显
        me.tkRowGuid = JSON.parse(res.data.data).Data[0].ROW_GUID

      }
    },
    async getFileData() {
      const res = await GJDBFunction2('get_Building_process', [{ record_guid: this.rowData.ROW_GUID, record_type: 2 }])
      console.log(res, 'dfnreiofnm')
      debugger
      res.forEach((item) => {
        if (item.NODE_NAME.slice(0, 3) == '村公示' || item.NODE_NAME == '村级预审' || !item.MODELNAME) {
        } else {
          //自动回显各个阶段的附件
          this.fileListData.push({
            title: item.MODELNAME,
            FileName: [],
            groupGuid: item.GROUPGUID,
            fileList: [],
            NODE_NAME: item.NODE_NAME
          })
        }
      })
      console.log(this.fileListData, 'this.fileListData')
    },
    onClickLeft() {
      this.$router.back(-1)
    }
  },
  created() {
    debugger
    this.getData(this.$route.query.PROC_GUID)
    this.getFileData()
    this.getData1()
    this.getTK();
  }
}
</script>
<style lang="scss" scoped>
.FileData {
  height: 95vh;
  background: #fff;
  font-size: 14px;
  font-family: 'Helvetica Neue', Helvetica, STHeiTi, sans-serif;
  padding: 10px;
  overflow: auto;

  .cardkls {
    p {
      height: 26px;
      line-height: 26px;
      font-size: 16px;
    }
  }

  .title {
    width: 100%;
    height: 50px;
    background: #007aff;
    line-height: 50px;
    text-align: center;
    color: #ffffff;
    font-size: 20px;
    position: relative;
  }

  .block {
    // height: calc(100vh - 50px);
    overflow: auto;
    padding: 4px;

    .year {
      position: absolute;
      right: 4px;
      top: -2px;
    }
  }
}
</style>

<style lang="scss">
.FileData {
  .el-timeline-item__timestamp {
    color: #208ffb;
    font-size: 16px;
    font-weight: 580;
  }

  .van-cell {
    padding-left: 0px;
    color: black;
    font-size: 16px;
  }

  .van-collapse-item__content {
    padding: 0;
    color: black;
  }

  #upLoad1 {
    padding: 0 !important;
  }

  [class*='van-hairline']::after {
    border: 0 !important;
  }
}
</style>
